package com.xiaoran.RMQ_1.test7_Topic;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.xiaoran.RMQ_1.utlis.RabbitMqUtils;

public class Topic_Consumer_2 {
    public static final String name="topic_logs";
    public static void main(String args[]) throws  Exception{
        Channel channel= RabbitMqUtils.getChannel();
        channel.exchangeDeclare(name,BuiltinExchangeType.TOPIC);
        channel.queueDeclare("Q2",false,false,false,null);
        channel.queueBind("Q2",name,"*.*.rabbit");
        channel.queueBind("Q2",name,"lazy.#");
        DeliverCallback deliverCallback=(consumerTag, message)->{
            System.out.println("获取到的消息是："+new String(message.getBody()));
        };
        CancelCallback cancelCallback= consumerTag->{

        };
        channel.basicConsume("Q2",true,deliverCallback,cancelCallback);
    }
}
